import Echart from '@cpt/echart'
import Pie from './pie.js'
import Line from './line.js'
import Empty from '@antd/empty'

const Index = ({ type, data, name, xdata, height=300 })=>{
	let _option = {}
	if( type === 'pie'){
		_option = Pie({data, name})
	}else if(type === 'line'){
		_option = Line({data, xdata, name})
	}
	
	return (
		<div className='rel fxmc' style={{height}}>
			{
				window.$fn.hasArray(data) ? <Echart option={_option} /> : <Empty data={[]} />
			}
			
		</div>
	)
}
	
export default Index